<?php
  $myDate = new Sfs_Date();
        list($locale, $timezone, $inTerritory,
        $set, $zd_year, $zd_month, $zd_day, $zd_hour, $zd_minute, $zd_second,
        $action, $part,
        $city, $useTz, $latitude, $longitude, $horizon,
        $result) = $myDate->process();
?>
 <p>EXAMPLE <?php Sfs_Html::printTitle();?></p>
    <hr />

    <form name="form">

      <table>

        <tr>
          <td>Locale</td>
          <td>
            <select name="locale">
              <option></option>
              <?php foreach(array_keys(Zend_Locale::getLocaleList()) as $name) :?>
                  <option value="<?php echo  $name;?>"
                          <?php Sfs_Html::printSelected($locale, $name);?>>
                    <?php echo  $name;?>
                  </option>
              <?php endforeach;?>
            </select>
          </td>
        </tr>

        <tr>
          <td>Timezone</td>
          <td>
            <select name="timezone">
              <option></option>
              <?php foreach(Sfs_Timezone::getTzTerritories(null, true) as $name) :?>
                  <option <?php Sfs_Html::printSelected($timezone, $name);?>>
                    <?php echo  $name;?>
                  </option>
              <?php endforeach;?>
            </select>
          </td>
        </tr>

        <tr>
          <td></td>
          <td>
            <input type="checkbox" name="in-territory" value="1"
                   <?php Sfs_Html::printChecked($inTerritory);?> />
            Must be in Locale Territory
          </td>
        </tr>

        <tr><td>&nbsp;</td></tr>

        <tr>
          <td>Set Date/Time</td>
          <td>
            <select name="set" onchange="resetDate()">
              <option></option>
              <option value="now" <?php Sfs_Html::printSelected($set, 'now');?>>Now</option>

              <optgroup label="Future from now">
                <option value="+1_hour" <?php Sfs_Html::printSelected($set, '+1_hour');?>>
                        One hour later</option>
                <option value="+1_day" <?php Sfs_Html::printSelected($set, '+1_day');?>>
                        Tomorrow</option>
                <option value="+1_month" <?php Sfs_Html::printSelected($set, '+1_month');?>>
                        One month later</option>
                <option value="+1_year" <?php Sfs_Html::printSelected($set, '+1_year');?>>
                        Next year</option>
                <option value="+100_year" <?php Sfs_Html::printSelected($set, '+100_year');?>>
                        In one century</option>
              </optgroup>

              <optgroup label="Past from now">
                <option value="-1_hour" <?php Sfs_Html::printSelected($set, '-1_hour');?>>
                        One hour ago</option>
                <option value="-1_day" <?php Sfs_Html::printSelected($set, '-1_day');?>>
                        Yesterday</option>
                <option value="-1_month" <?php Sfs_Html::printSelected($set, '-1_month');?>>
                        One month ago</option>
                <option value="-1_year" <?php Sfs_Html::printSelected($set, '-1_year');?>>
                        Last year</option>
                <option value="-100_year" <?php Sfs_Html::printSelected($set, '-100_year');?>>
                        One century ago</option>
              </optgroup>
              </select>
          </td>
        </tr>

        <tr>
          <td>OR</td>
          <td>
            <input type="text" name="year" value="<?php echo  $zd_year;?>"
                   class="long" onchange="resetSet()" /> /
            <input type="text" name="month" value="<?php echo  $zd_month;?>"
                   class="short" onchange="resetSet()" /> /
            <input type="text" name="day" value="<?php echo  $zd_day;?>"
                   class="short" onchange="resetSet()" />
            &nbsp;
            <input type="text" name="hour" value="<?php echo  $zd_hour;?>"
                   class="short" onchange="resetSet()" /> :
            <input type="text" name="minute" value="<?php echo  $zd_minute;?>"
                   class="short" onchange="resetSet()" /> :
            <input type="text" name="second" value="<?php echo  $zd_second;?>"
                   class="short" onchange="resetSet()" />
          </td>
          <td>Example: 2009/12/10 12:34:56</td>
        </tr>

        <tr><td>&nbsp;</td></tr>

        <tr>
          <td>Action</td>
          <td>
            <select name="action">
              <optgroup label="output">
                <option <?php Sfs_Html::printSelected($action, 'get');?>>get</option>
                <option <?php Sfs_Html::printSelected($action, 'toString');?>>toString</option>
                <option <?php Sfs_Html::printSelected($action, 'toArray');?>>toArray</option>
                <option <?php Sfs_Html::printSelected($action, 'toValue');?>>toValue</option>
                <option <?php Sfs_Html::printSelected($action, 'Zend_Date');?>>Zend_Date</option>
              </optgroup>

              <optgroup label="is*">
                <option <?php Sfs_Html::printSelected($action, 'isLeapYear');?>>isLeapYear</option>
                <option <?php Sfs_Html::printSelected($action, 'isToday');?>>isToday</option>
                <option <?php Sfs_Html::printSelected($action, 'isTomorrow');?>>isTomorrow</option>
                <option <?php Sfs_Html::printSelected($action, 'isYesterday');?>>isYesterday</option>
              </optgroup>

              <optgroup label="compare">
                <option value="compare-now"
                        <?php Sfs_Html::printSelected($action, 'compare-now');?>>compare to now</option>
                <option value="compare-12"
                        <?php Sfs_Html::printSelected($action, 'compare-12');?>>compare to 12:**:**</option>
              </optgroup>

              <optgroup label="equals">
                <option value="equals-now"
                        <?php Sfs_Html::printSelected($action, 'equals-now');?>>equals now</option>
                <option value="equals-12"
                        <?php Sfs_Html::printSelected($action, 'equals-12');?>>equals 12:**:**</option>
              </optgroup>

              <optgroup label="getSun*">
                <option <?php Sfs_Html::printSelected($action, 'getSunrise');?>>getSunrise</option>
                <option <?php Sfs_Html::printSelected($action, 'getSunset');?>>getSunset</option>
                <option <?php Sfs_Html::printSelected($action, 'getSunInfo');?>>getSunInfo</option>
              </optgroup>
            </select>
          </td>
        </tr>

        <tr><td>&nbsp;</td></tr>

        <tr>
          <td>Part</td>
          <td>
            <select name="part">
              <option></option>
              <?php foreach(Sfs_Html::getConstants('Zend_Date') as $name => $value) :?>
                  <option value="<?php echo  $value;?>"
                          <?php Sfs_Html::printSelected($part, $value);?>>
                    <?php echo  $name;?>
                  </option>
              <?php endforeach;?>
            </select>
          </td>
          <td>Only applies to the methods: get, toString, toValue, getSunrise, getSunset.</td>
        </tr>

        <tr><td>&nbsp;</td></tr>

        <tr>
          <td>City</td>
          <td>
            <select name="city" onchange="resetLocation()">
              <option></option>
              <?php foreach(Zend_Date_Cities::getCityList() as $name) :?>
                  <option <?php Sfs_Html::printSelected($city, $name);?>>
                    <?php echo  $name;?>
                  </option>
              <?php endforeach;?>
            </select>
          </td>
          <td>Only applies to the getSun* methods.</td>
        </tr>

        <tr>
          <td>OR</td>
          <td>
            <input type="checkbox" name="use-tz" value="1"
                   <?php Sfs_Html::printChecked($useTz);?> />
            Use Timezone City if possible.
          </td>
        </tr>

        <tr>
          <td>Location</td>
          <td>
            Lat.  <input type="text" name="latitude" value="<?php echo  $latitude;?>"
                   class="degree" onchange="resetCity()" />
            &nbsp;
            Long. <input type="text" name="longitude" value="<?php echo  $longitude;?>"
                   class="degree" onchange="resetCity()" />
            &nbsp;
            <select name="horizon">
              <option value="" <?php Sfs_Html::printSelected($horizon, 'effective');?>>
                effective</option>
              <option <?php Sfs_Html::printSelected($horizon, 'civil');?>>
                civil</option>
              <option <?php Sfs_Html::printSelected($horizon, 'nautic');?>>
                nautic</option>
              <option <?php Sfs_Html::printSelected($horizon, 'astronomic');?>>
                astronomic</option>
            </select>
          </td>
          <td>Example: Lat. 51.50 Long. -0.13</td>
        </tr>

        <tr><td>&nbsp;</td></tr>

        <tr>
          <td></td>
          <td>
            <input type="submit" value="Submit" />
            <br /> <br />
            <a href="date.php">Reset to current Locale</a>
          </td>
        </tr>

      </table>
    </form>

    <hr />
    RESULT
    <?php Sfs_Html::colorize($result);?>

    <script type="text/javascript">
      function resetDate()
      {
          form.year.value='';
          form.month.value='';
          form.day.value='';
          form.hour.value='';
          form.minute.value='';
          form.second.value='';
      }

      function resetSet()
      {
          form.set.selectedIndex = 0;
      }

      function resetLocation()
      {
          form.latitude.value='';
          form.longitude.value='';
      }

      function resetCity()
      {
          form.city.selectedIndex = 0;
      }
    </script>